package cn.edu.bcu.ls.controller;

import cn.edu.bcu.ls.entity.Order;
import cn.edu.bcu.ls.serviceImpl.OrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @ApiOperation(value = "上传订单，传入你想要的传的值就行")
    @PostMapping(value="order")
    public boolean insertOrder(Order order) {
        if (orderService.insert(order) >0) {
            return true;
        }else {
            return false;
        }
    }

    @ApiOperation(value="修改订单，传入id和想修改的值")
    @PutMapping(value="order")
    public boolean updateOrder(Order order) {
        if (orderService.update(order) >0) {
            return true;
        }else {
            return false;
        }
    }

    @ApiOperation(value = "删除订单，传入id")
    @DeleteMapping(value="order/{o_id}")
    public boolean deleteUser(@PathVariable("o_id") Integer o_id) {
        if (orderService.deleteByPrimaryKey(o_id) >0) {
            return true;
        }else {
            return false;
        }
    }

    @GetMapping(value="order")
    public List<Order> queryOrders(Integer o_id,Integer c_id,Integer u_id){
        return orderService.selectByPrimaryKey(o_id,c_id,u_id);
    }
    
    
    @ApiOperation(value = "订单支付，根据接口获得支付宝二维码图片")
    @GetMapping(value="orderPayPic")
    public String orderPay(){
    	String paypic = "http://www.lszjx.com:8080/upload/a7e96076-3999-4897-bf45-a8747e18b0be.jpg";
        return paypic ;
    }
}
